import Vue from 'vue'
import Vuex from 'vuex'
// import axios from 'axios';
// import urls from './common';

Vue.use(Vuex)
let rolename = localStorage.getItem('rolename')||'',username=localStorage.getItem('username')||'',
roleplatname = localStorage.getItem('roleplatname')||'',userplatname=localStorage.getItem('userplatname')||'',
userid=localStorage.getItem('userid')||'',userplatid=localStorage.getItem('userplatid')||'',
resInfo=localStorage.getItem('resInfo')||'',
applyInfo=localStorage.getItem('applyInfo')||'',roleid=localStorage.getItem('roleid')||'',
rolePlatid=localStorage.getItem('roleplatid')||'';
// try {
//   if (localStorage.getItem('rolename')) {
    
//   }else{
//     rolename = localStorage.getItem('rolename')
//   }
//   if(localStorage.getItem('username')){

//   }else{
//     username = localStorage.getItem('username')
//   }
// } catch (e) {
  
// }
export default new Vuex.Store({
  state: {
    rolename: rolename,
    username: username,
    userid:userid,
    roleid:roleid,
    rolePlatid:rolePlatid,
    userplatid:userplatid,
    resInfo:{},
    applyInfo:{},
    roleplatname:roleplatname,
    userplatname:userplatname,
    caseNo:'',
    payPic:'',
    isShows:true,
    isUploadBtn:true,
    dealThing:0,
    needAmont:0
  },
  actions: { // 获取数据
    changeRolename: function (ctx, rolename) { // ctx 指的是上下文  接受值
      ctx.commit('changeRolename', rolename) // commit 两个参数 自定义事件名称 和数据
    },
    changeUsername: function (ctx, username) {
      ctx.commit('changeUsername', username)
    },
    changeRolePlatname: function (ctx, rolename) { // ctx 指的是上下文  接受值
      ctx.commit('changeRolePlatname', rolename) // commit 两个参数 自定义事件名称 和数据
    },
    changeUserPlatname: function (ctx, username) {
      ctx.commit('changeUserPlatname', username)
    },
    changeUserid: function (ctx, userid) {
      ctx.commit('changeUserid', userid)
    },
    changeUserPlatid: function (ctx, userplatid) {
      ctx.commit('changeUserPlatid', userplatid)
    },
    changeResInfo: function (ctx, resInfo) {
      ctx.commit('changeResInfo', resInfo)
    },
    changeapplyInfo: function (ctx, applyInfo) {
      ctx.commit('changeapplyInfo', applyInfo)
    },
    changeRoleid: function (ctx, roleid) {
      ctx.commit('changeRoleid', roleid)
    },
    changePlatRoleid: function (ctx, rolePlatid) {
      ctx.commit('changePlatRoleid', rolePlatid)
    }
  },
  mutations: {
    changeRolename: function (state, rolename) {
      state.rolename = rolename
    },
    changeUsername: function (state, username) {
      state.username = username
    },
    changeRolePlatname: function (state, roleplatname) {
      state.roleplatname = roleplatname
    },
    changeUserPlatname: function (state, userplatname) {
      state.userplatname = userplatname
    },
    changeUserid: function (state, userid) {
      state.userid = userid
    },
    changeUserPlatid: function (state, userplatid) {
      state.userplatid = userplatid
    },
    changeRoleid: function (state, roleid) {
      state.roleid = roleid
    },
    changePlatRoleid: function (state, rolePlatid) {
      state.rolePlatid = rolePlatid
    },
    changeResInfo: function (state, resInfo) {
      state.resInfo = resInfo
    },
    changeapplyInfo: function (state, applyInfo) {
      state.applyInfo = applyInfo
    },
    isShow:function(state, isShows){
      state.isShows = isShows
    },
    dealThing:function(state, dealThing){
      state.dealThing = dealThing
    },
    needAmont:function(state, needAmont){
      state.needAmont = needAmont
    }
  }
})
